#include "asm.h"
#include "regdef.h"
#include "inst_test.h"

LEAF(n42_ld_h_test)
    
    addi.w s0, s0 ,1
    li  s2, 0x0
###test inst
    TEST_LD_H(0x51842560, 0xd2bc4, 0x000027c, 0x000027c, 0x00002560)
    TEST_LD_H(0x2516116e, 0xd2220, 0x0000890, 0x0000890, 0x0000116e)
    TEST_LD_H(0x4932330c, 0xd3810, 0x0000526, 0x0000524, 0x00004932)
    TEST_LD_H(0xbe4d9ac8, 0xdac60, 0x0000092, 0x0000090, 0xffffbe4d)
    TEST_LD_H(0x5f0c0856, 0xd1800, 0x0000964, 0x0000964, 0x00000856)
    TEST_LD_H(0xbfa5bc80, 0xd9ca0, 0x0000950, 0x0000950, 0xffffbc80)
    TEST_LD_H(0x67b0ca80, 0xdb258, 0x0000f74, 0x0000f74, 0xffffca80)
    TEST_LD_H(0xb0c4ee88, 0xd0a08, 0x00009d4, 0x00009d4, 0xffffee88)
    TEST_LD_H(0xa28fbedc, 0xd130c, 0x0000f28, 0x0000f28, 0xffffbedc)
    TEST_LD_H(0x01589400, 0xd3568, 0x0000f36, 0x0000f34, 0x00000158)
    TEST_LD_H(0x20483e02, 0xdd600, 0x0000e7c, 0x0000e7c, 0x00003e02)
    TEST_LD_H(0x61718b00, 0xd8550, 0x00004e0, 0x00004e0, 0xffff8b00)
    TEST_LD_H(0xb2044740, 0xd1a30, 0x0000d88, 0x0000d88, 0x00004740)
    TEST_LD_H(0x6dbe93b6, 0xd2a08, 0x00003e0, 0x00003e0, 0xffff93b6)
    TEST_LD_H(0xe96e7db0, 0xd25e8, 0x000050a, 0x0000508, 0xffffe96e)
    TEST_LD_H(0x6737a118, 0xd4f78, 0x0000fae, 0x0000fac, 0x00006737)
    TEST_LD_H(0x2fec7a40, 0xd5228, 0x0000466, 0x0000464, 0x00002fec)
    TEST_LD_H(0x5805df3d, 0xde870, 0x0000454, 0x0000454, 0xffffdf3d)
    TEST_LD_H(0x4ea0d20c, 0xd2194, 0x00007c8, 0x00007c8, 0xffffd20c)
    TEST_LD_H(0x7bf8d942, 0xd5d50, 0x0000000, 0x0000000, 0xffffd942)
    TEST_LD_H(0x37ee910e, 0xd97f0, 0x0000174, 0x0000174, 0xffff910e)
    TEST_LD_H(0x02593920, 0xd23b8, 0x000000c, 0x000000c, 0x00003920)
    TEST_LD_H(0xb7e21268, 0xdcba8, 0x000021c, 0x000021c, 0x00001268)
    TEST_LD_H(0x0074b9d0, 0xd17a8, 0x000028c, 0x000028c, 0xffffb9d0)
    TEST_LD_H(0x1326e800, 0xd0848, 0x000016e, 0x000016c, 0x00001326)
    TEST_LD_H(0xb42e5a40, 0xd3b34, 0x00004d8, 0x00004d8, 0x00005a40)
    TEST_LD_H(0x783e0a00, 0xd7838, 0x0000c3c, 0x0000c3c, 0x00000a00)
    TEST_LD_H(0xd6942958, 0xd53a8, 0x000064a, 0x0000648, 0xffffd694)
    TEST_LD_H(0x9d237d60, 0xd0600, 0x000090c, 0x000090c, 0x00007d60)
    TEST_LD_H(0x098f2730, 0xd1b58, 0x00008a8, 0x00008a8, 0x00002730)
    TEST_LD_H(0x2ab8ce90, 0xd31ec, 0x00008d0, 0x00008d0, 0xffffce90)
    TEST_LD_H(0x37fdbec8, 0xd4890, 0x0000bd2, 0x0000bd0, 0x000037fd)
    TEST_LD_H(0x34fc33ac, 0xd5448, 0x00006d2, 0x00006d0, 0x000034fc)
    TEST_LD_H(0xdcc144c8, 0xd6940, 0x000073c, 0x000073c, 0x000044c8)
    TEST_LD_H(0x3354e5b4, 0xd5834, 0x0000926, 0x0000924, 0x00003354)
    TEST_LD_H(0xb5e7da8e, 0xdcc78, 0x0000800, 0x0000800, 0xffffda8e)
    TEST_LD_H(0x8c87a650, 0xd2d9c, 0x0000440, 0x0000440, 0xffffa650)
    TEST_LD_H(0x3df29bc0, 0xd0000, 0x000034e, 0x000034c, 0x00003df2)
    TEST_LD_H(0x975c3a5c, 0xd0000, 0x00008cc, 0x00008cc, 0x00003a5c)
    TEST_LD_H(0x29ab53d6, 0xd0000, 0x00009e8, 0x00009e8, 0x000053d6)
    TEST_LD_H(0x763b2600, 0xd0000, 0x0000e7c, 0x0000e7c, 0x00002600)
    TEST_LD_H(0x774ed370, 0xd0000, 0x0000760, 0x0000760, 0xffffd370)
    TEST_LD_H(0x8e24d680, 0xd0000, 0x0000fe0, 0x0000fe0, 0xffffd680)
    TEST_LD_H(0xfe3936cb, 0xd0000, 0x00007b0, 0x00007b0, 0x000036cb)
    TEST_LD_H(0x0b892a40, 0xd0000, 0x000003a, 0x0000038, 0x00000b89)
    TEST_LD_H(0xd92fe108, 0xd0000, 0x0000d48, 0x0000d48, 0xffffe108)
    TEST_LD_H(0x4c4bc954, 0xd0000, 0x0000258, 0x0000258, 0xffffc954)
    TEST_LD_H(0xb7baba40, 0xd0000, 0x0000106, 0x0000104, 0xffffb7ba)
    TEST_LD_H(0x8a754a34, 0xd0000, 0x00003a8, 0x00003a8, 0x00004a34)
    TEST_LD_H(0x062c0990, 0xd0000, 0x00007c0, 0x00007c0, 0x00000990)
    TEST_LD_H(0xf3c0fc50, 0xd0000, 0x0000692, 0x0000690, 0xfffff3c0)
    TEST_LD_H(0x941e1b70, 0xd0000, 0x0000544, 0x0000544, 0x00001b70)
    TEST_LD_H(0x06a8f600, 0xd0000, 0x000014e, 0x000014c, 0x000006a8)
    TEST_LD_H(0xf0c9f8c0, 0xd0000, 0x0000156, 0x0000154, 0xfffff0c9)
    TEST_LD_H(0x6d67df7c, 0xd0000, 0x0000ce6, 0x0000ce4, 0x00006d67)
    TEST_LD_H(0x7b5c8c40, 0xd0000, 0x0000170, 0x0000170, 0xffff8c40)
    TEST_LD_H(0xa01d88d6, 0xd0000, 0x0000236, 0x0000234, 0xffffa01d)
    TEST_LD_H(0xbb91715e, 0xd0000, 0x0000a5e, 0x0000a5c, 0xffffbb91)
    TEST_LD_H(0xa2086268, 0xd0000, 0x0000e6c, 0x0000e6c, 0x00006268)
    TEST_LD_H(0xc16e7fd2, 0xd0000, 0x00000e4, 0x00000e4, 0x00007fd2)
    TEST_LD_H(0xf26f0540, 0xd0000, 0x0000fb8, 0x0000fb8, 0x00000540)
    TEST_LD_H(0x5df5b227, 0xd0000, 0x0000b56, 0x0000b54, 0x00005df5)
    TEST_LD_H(0x17cb2286, 0xd0000, 0x0000610, 0x0000610, 0x00002286)
    TEST_LD_H(0xcc5b2bee, 0xd0000, 0x0000a32, 0x0000a30, 0xffffcc5b)
    TEST_LD_H(0xf148bba0, 0xd0000, 0x00000d2, 0x00000d0, 0xfffff148)
    TEST_LD_H(0x337725a6, 0xd0000, 0x000062e, 0x000062c, 0x00003377)
    TEST_LD_H(0x2982116c, 0xd0000, 0x0000980, 0x0000980, 0x0000116c)
    TEST_LD_H(0xf335ae26, 0xd0000, 0x0000e14, 0x0000e14, 0xffffae26)
    TEST_LD_H(0x1cea3011, 0xd0000, 0x0000610, 0x0000610, 0x00003011)
    TEST_LD_H(0x5288a4be, 0xd0000, 0x00000e0, 0x00000e0, 0xffffa4be)
    TEST_LD_H(0xaba58c80, 0xd0000, 0x0000ecc, 0x0000ecc, 0xffff8c80)
    TEST_LD_H(0x878018c0, 0xd0000, 0x0000a08, 0x0000a08, 0x000018c0)
    TEST_LD_H(0xdcfe7908, 0xd0000, 0x0000002, 0x0000000, 0xffffdcfe)
    TEST_LD_H(0xca7e2534, 0xd0000, 0x0000000, 0x0000000, 0x00002534)
    TEST_LD_H(0x3a5f5000, 0xd0000, 0x0000000, 0x0000000, 0x00005000)
    TEST_LD_H(0xc087931c, 0xd0000, 0x0000000, 0x0000000, 0xffff931c)
    TEST_LD_H(0x0352c2b4, 0xd0000, 0x0000002, 0x0000000, 0x00000352)
    TEST_LD_H(0x674236b0, 0xd0000, 0x0000000, 0x0000000, 0x000036b0)
    TEST_LD_H(0xb8008adc, 0xd0000, 0x0000002, 0x0000000, 0xffffb800)
    TEST_LD_H(0x9368c576, 0xd0000, 0x0000000, 0x0000000, 0xffffc576)
    TEST_LD_H(0xfba1ce40, 0xd0000, 0x0000000, 0x0000000, 0xffffce40)
    TEST_LD_H(0x585c5e30, 0xd0000, 0x0000000, 0x0000000, 0x00005e30)
    TEST_LD_H(0x9915f89c, 0xd0000, 0x0000000, 0x0000000, 0xfffff89c)
    TEST_LD_H(0x8aefa220, 0xd0000, 0x0000002, 0x0000000, 0xffff8aef)
    TEST_LD_H(0x42ccca62, 0xd0000, 0x0000000, 0x0000000, 0xffffca62)
    TEST_LD_H(0x00000000, 0xd0000, 0x0000000, 0x0000000, 0x00000000)
###detect exception
    bne s2, zero, inst_error
###score ++
    addi.w s3, s3, 1
###output (s0<<24)|s3
inst_error:  
    slli.w t1, s0, 24
    NOP4
    or t0, t1, s3 
    NOP4
    st.w t0, s1, 0
    jirl zero, ra, 0
END(n42_ld_h_test)
